<?php

$domain=$_POST['domain'];
$net=$_POST['net'];
$netmask=$_POST['netmask'];
$ip1=$_POST['ip1'];
$ip2=$_POST['ip2'];
$gw=$_POST['gw'];
$dns1=$_POST['dns1'];
$dns2=$_POST['dns2'];

$DBHANDLER = sqlite_open('dhcpd.sqlite');
$save_query = sqlite_exec( $DBHANDLER , "INSERT INTO redes VALUES ('$domain','$net','$netmask','$ip1','$ip2','$gw','$dns1','$dns2','1')");

require("dhcpd.php");


sqlite_close($DBHANDLER);







/*


$conf ='conf.php';
$file2 = fopen($conf,"w+");
fwrite($file2,$confconteudo);
fclose($file2);

//descomentar se necessário
//chmod($conf,0700);

//-----------------------------------------------------------------------------


$conteudo = "
ddns-update-style none;
one-lease-per-client on;
log-facility local7;

subnet $net netmask $netmask {
range $ip1 $ip2;
option routers $gw;
option domain-name \"$domain\";
default-lease-time 600;
max-lease-time 7200;
option domain-name-servers $dns1,$dns2 ;
}\n\n\n";


$dhcpfile ='dhcpd.conf';
$file = fopen($dhcpfile,"w+");
fwrite($file,$conteudo);
fclose($file);
descomentar se necessário
chmod($dhcpfile,0700);



//alterado///////////////////////
require("dhcp_lib.php");

create_dhcp_conf_file()



//$command_dhcpd = 'sudo cp dhcpd.conf /etc/dhcp3/dhcpd.conf ; sudo /etc/init.d/dhcp3-server start >> /dev/null';
//system("$command_dhcpd",$ret);


include ("page_start.php");
if ( $ret == "0" ){
	echo "<center><h3>O Servidor DHCP está funcionando corretamente.</h3><p>
	<a href=\"dhcpd.php\">VOLTAR</a></a></center>";
	include ("page_end.php");
	} elseif ( $ret != "0" ){
		echo "<center><h3>O Servidor não está funcioando corretamente.<br><a href=mailto:\"slackjr@gmail.com\">Entre em contato com o suporte.</h3></a></center><hr>";
		include ("page_end.php");
		}

*/
?>